package com.rw.pay.controller;


import com.rw.common.entity.Receive;
import com.rw.pay.service.ReceiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 领取表 前端控制器
 * </p>
 *
 * @author Rabit
 * @since 2021-12-20
 */
@Controller
@RequestMapping("/common/receive")
public class ReceiveController {

    @Autowired
    private ReceiveService receiveService;

    /**
     * 领取优惠券或者抢优惠券的接口
     * @return
     */
    @PostMapping("save")
    public Map<String, Object> receiveData(@RequestBody Receive receive){
        Map<String, Object> map =new HashMap<>();
        map.put("code",200);
        //需要在service中实现业务逻辑
        boolean flag=receiveService.getReceiveByUser(receive);
        if (flag){
            map.put("msg","抢券成功");
        }else {
            map.put("msg","没抢到");
        }
        return map;
    }
}

